home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Printing.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  13.7 KB  |  461 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Printing.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __PRINTING__
  18. #define __PRINTING__
  19.  
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <Types.h>                                            */
  30. /*    #include <MixedMode.h>                                        */
  31. /*    #include <QuickdrawText.h>                                    */
  32.  
  33. #ifndef __DIALOGS__
  34. #include <Dialogs.h>
  35. #endif
  36. /*    #include <Memory.h>                                            */
  37. /*    #include <Windows.h>                                        */
  38. /*        #include <Events.h>                                        */
  39. /*            #include <OSUtils.h>                                */
  40. /*        #include <Controls.h>                                    */
  41. /*            #include <Menus.h>                                    */
  42. /*    #include <TextEdit.h>                                        */
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. #if GENERATINGPOWERPC
  49. #pragma options align=mac68k
  50. #endif
  51.  
  52. #ifdef __CFM68K__
  53. #pragma lib_export on
  54. #endif
  55.  
  56.  
  57. enum {
  58.     iPFMaxPgs                    = 128,
  59.     iPrPgFract                    = 120,                            /*Page scale factor. ptPgSize (below) is in units of 1/iPrPgFract*/
  60.     iPrPgFst                    = 1,                            /*Page range constants*/
  61.     iPrPgMax                    = 9999,
  62.     iPrRelease                    = 3,                            /*Current version number of the code.*/
  63.     iPrSavPFil                    = -1,
  64.     iPrAbort                    = 0x0080,
  65.     iPrDevCtl                    = 7,                            /*The PrDevCtl Proc's ctl number*/
  66.     lPrReset                    = 0x00010000,                    /*The PrDevCtl Proc's CParam for reset*/
  67.     lPrLineFeed                    = 0x00030000,
  68.     lPrLFStd                    = 0x0003FFFF,                    /*The PrDevCtl Proc's CParam for std paper advance*/
  69.     lPrLFSixth                    = 0x0003FFFF,
  70.     lPrPageEnd                    = 0x00020000,                    /*The PrDevCtl Proc's CParam for end page*/
  71.     lPrDocOpen                    = 0x00010000,
  72.     lPrPageOpen                    = 0x00040000,
  73.     lPrPageClose                = 0x00020000,
  74.     lPrDocClose                    = 0x00050000,
  75.     iFMgrCtl                    = 8,                            /*The FMgr's Tail-hook Proc's ctl number*/
  76.     iMscCtl                        = 9,                            /*The FMgr's Tail-hook Proc's ctl number*/
  77.     iPvtCtl                        = 10                            /*The FMgr's Tail-hook Proc's ctl number*/
  78. };
  79.  
  80. #define sPrDrvr ".Print"
  81. enum {
  82.     pPrGlobals                    = 0x00000944,                    /*The PrVars lo mem area:*/
  83.     bDraftLoop                    = 0,
  84.     bSpoolLoop                    = 1,
  85.     bUser1Loop                    = 2,
  86.     bUser2Loop                    = 3,
  87.     fNewRunBit                    = 2,
  88.     fHiResOK                    = 3,
  89.     fWeOpenedRF                    = 4,
  90. /*Driver constants */
  91.     iPrBitsCtl                    = 4,
  92.     lScreenBits                    = 0,
  93.     lPaintBits                    = 1,
  94.     lHiScreenBits                = 0x00000002,                    /*The Bitmap Print Proc's Screen Bitmap param*/
  95.     lHiPaintBits                = 0x00000003,                    /*The Bitmap Print Proc's Paint [sq pix] param*/
  96.     iPrIOCtl                    = 5,
  97.     iPrEvtCtl                    = 6,                            /*The PrEvent Proc's ctl number*/
  98.     lPrEvtAll                    = 0x0002FFFD,                    /*The PrEvent Proc's CParam for the entire screen*/
  99.     lPrEvtTop                    = 0x0001FFFD,                    /*The PrEvent Proc's CParam for the top folder*/
  100.     iPrDrvrRef                    = -3
  101. };
  102.  
  103. enum {
  104.     getRslDataOp                = 4,
  105.     setRslOp                    = 5,
  106.     draftBitsOp                    = 6,
  107.     noDraftBitsOp                = 7,
  108.     getRotnOp                    = 8,
  109.     NoSuchRsl                    = 1,
  110.     OpNotImpl                    = 2,                            /*the driver doesn't support this opcode*/
  111.     RgType1                        = 1
  112. };
  113.  
  114. enum {
  115.     feedCut,
  116.     feedFanfold,
  117.     feedMechCut,
  118.     feedOther
  119. };
  120.  
  121. typedef SInt8 TFeed;
  122.  
  123.  
  124. enum {
  125.     scanTB,
  126.     scanBT,
  127.     scanLR,
  128.     scanRL
  129. };
  130.  
  131. typedef SInt8 TScan;
  132.  
  133. /* A Rect Ptr */
  134. typedef Rect *TPRect;
  135.  
  136. typedef pascal void (*PrIdleProcPtr)(void);
  137.  
  138. #if GENERATINGCFM
  139. typedef UniversalProcPtr PrIdleUPP;
  140. #else
  141. typedef PrIdleProcPtr PrIdleUPP;
  142. #endif
  143.  
  144. enum {
  145.     uppPrIdleProcInfo = kPascalStackBased
  146. };
  147.  
  148. #if GENERATINGCFM
  149. #define NewPrIdleProc(userRoutine)        \
  150.         (PrIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppPrIdleProcInfo, GetCurrentArchitecture())
  151. #else
  152. #define NewPrIdleProc(userRoutine)        \
  153.         ((PrIdleUPP) (userRoutine))
  154. #endif
  155.  
  156. #if GENERATINGCFM
  157. #define CallPrIdleProc(userRoutine)        \
  158.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppPrIdleProcInfo)
  159. #else
  160. #define CallPrIdleProc(userRoutine)        \
  161.         (*(userRoutine))()
  162. #endif
  163.  
  164. typedef pascal void (*PItemProcPtr)(DialogPtr theDialog, short item);
  165.  
  166. #if GENERATINGCFM
  167. typedef UniversalProcPtr PItemUPP;
  168. #else
  169. typedef PItemProcPtr PItemUPP;
  170. #endif
  171.  
  172. enum {
  173.     uppPItemProcInfo = kPascalStackBased
  174.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  175.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  176. };
  177.  
  178. #if GENERATINGCFM
  179. #define NewPItemProc(userRoutine)        \
  180.         (PItemUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppPItemProcInfo, GetCurrentArchitecture())
  181. #else
  182. #define NewPItemProc(userRoutine)        \
  183.         ((PItemUPP) (userRoutine))
  184. #endif
  185.  
  186. #if GENERATINGCFM
  187. #define CallPItemProc(userRoutine, theDialog, item)        \
  188.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppPItemProcInfo, (theDialog), (item))
  189. #else
  190. #define CallPItemProc(userRoutine, theDialog, item)        \
  191.         (*(userRoutine))((theDialog), (item))
  192. #endif
  193.  
  194. struct TPrPort {
  195.     GrafPort                        gPort;                        /*The Printer's graf port.*/
  196.     QDProcs                            gProcs;                        /*..and its procs*/
  197.     long                            lGParam1;                    /*16 bytes for private parameter storage.*/
  198.     long                            lGParam2;
  199.     long                            lGParam3;
  200.     long                            lGParam4;
  201.     Boolean                            fOurPtr;                    /*Whether the PrPort allocation was done by us.*/
  202.     Boolean                            fOurBits;                    /*Whether the BitMap allocation was done by us.*/
  203. };
  204. typedef struct TPrPort TPrPort, *TPPrPort;
  205.  
  206. /* Printing Graf Port. All printer imaging, whether spooling, banding, etc, happens "thru" a GrafPort.
  207.   This is the "PrPeek" record. */
  208. struct TPrInfo {
  209.     short                            iDev;                        /*Font mgr/QuickDraw device code*/
  210.     short                            iVRes;                        /*Resolution of device, in device coordinates*/
  211.     short                            iHRes;                        /*..note: V before H => compatable with Point.*/
  212.     Rect                            rPage;                        /*The page (printable) rectangle in device coordinates.*/
  213. };
  214. typedef struct TPrInfo TPrInfo, *TPPrInfo;
  215.  
  216. /* Print Info Record: The parameters needed for page composition. */
  217. struct TPrStl {
  218.     short                            wDev;
  219.     short                            iPageV;
  220.     short                            iPageH;
  221.     SInt8                            bPort;
  222.     TFeed                            feed;
  223. };
  224. typedef struct TPrStl TPrStl, *TPPrStl;
  225.  
  226. struct TPrXInfo {
  227.     short                            iRowBytes;
  228.     short                            iBandV;
  229.     short                            iBandH;
  230.     short                            iDevBytes;
  231.     short                            iBands;
  232.     SInt8                            bPatScale;
  233.     SInt8                            bUlThick;
  234.     SInt8                            bUlOffset;
  235.     SInt8                            bUlShadow;
  236.     TScan                            scan;
  237.     SInt8                            bXInfoX;
  238. };
  239. typedef struct TPrXInfo TPrXInfo, *TPPrXInfo;
  240.  
  241. struct TPrJob {
  242.     short                            iFstPage;                    /*Page Range.*/
  243.     short                            iLstPage;
  244.     short                            iCopies;                    /*No. copies.*/
  245.     SInt8                            bJDocLoop;                    /*The Doc style: Draft, Spool, .., and ..*/
  246.     Boolean                            fFromUsr;                    /*Printing from an User's App (not PrApp) flag*/
  247.     PrIdleUPP                        pIdleProc;                    /*The Proc called while waiting on IO etc.*/
  248.     StringPtr                        pFileName;                    /*Spool File Name: NIL for default.*/
  249.     short                            iFileVol;                    /*Spool File vol, set to 0 initially*/
  250.     SInt8                            bFileVers;                    /*Spool File version, set to 0 initially*/
  251.     SInt8                            bJobX;                        /*An eXtra byte.*/
  252. };
  253. typedef struct TPrJob TPrJob, *TPPrJob;
  254.  
  255. /* Print Job: Print "form" for a single print request. */
  256. struct TPrint {
  257.     short                            iPrVersion;                    /*(2) Printing software version*/
  258.     TPrInfo                            prInfo;                        /*(14) the PrInfo data associated with the current style.*/
  259.     Rect                            rPaper;                        /*(8) The paper rectangle [offset from rPage]*/
  260.     TPrStl                            prStl;                        /*(8)  This print request's style.*/
  261.     TPrInfo                            prInfoPT;                    /*(14)  Print Time Imaging metrics*/
  262.     TPrXInfo                        prXInfo;                    /*(16)  Print-time (expanded) Print info record.*/
  263.     TPrJob                            prJob;                        /*(20) The Print Job request (82)  Total of the above; 120-82 = 38 bytes needed to fill 120*/
  264.     short                            printX[19];                    /*Spare to fill to 120 bytes!*/
  265. };
  266. typedef struct TPrint TPrint, *TPPrint, **THPrint;
  267.  
  268. /* The universal 120 byte printing record */
  269. struct TPrStatus {
  270.     short                            iTotPages;                    /*Total pages in Print File.*/
  271.     short                            iCurPage;                    /*Current page number*/
  272.     short                            iTotCopies;                    /*Total copies requested*/
  273.     short                            iCurCopy;                    /*Current copy number*/
  274.     short                            iTotBands;                    /*Total bands per page.*/
  275.     short                            iCurBand;                    /*Current band number*/
  276.     Boolean                            fPgDirty;                    /*True if current page has been written to.*/
  277.     Boolean                            fImaging;                    /*Set while in band's DrawPic call.*/
  278.     THPrint                            hPrint;                        /*Handle to the active Printer record*/
  279.     TPPrPort                        pPrPort;                    /*Ptr to the active PrPort*/
  280.     PicHandle                        hPic;                        /*Handle to the active Picture*/
  281. };
  282. typedef struct TPrStatus TPrStatus, *TPPrStatus;
  283.  
  284. /* Print Status: Print information during printing. */
  285. struct TPfPgDir {
  286.     short                            iPages;
  287.     long                            iPgPos[129];                /*ARRAY [0..iPfMaxPgs] OF LONGINT*/
  288. };
  289. typedef struct TPfPgDir TPfPgDir, *TPPfPgDir, **THPfPgDir;
  290.  
  291. /* PicFile = a TPfHeader followed by n QuickDraw Pics (whose PicSize is invalid!) */
  292. struct TPrDlg {
  293.     DialogRecord                    Dlg;                        /*The Dialog window*/
  294.     ModalFilterUPP                    pFltrProc;                    /*The Filter Proc.*/
  295.     PItemUPP                        pItemProc;                    /*The Item evaluating proc.*/
  296.     THPrint                            hPrintUsr;                    /*The user's print record.*/
  297.     Boolean                            fDoIt;
  298.     Boolean                            fDone;
  299.     long                            lUser1;                        /*Four longs for user's to hang global data.*/
  300.     long                            lUser2;                        /*...Plus more stuff needed by the particular printing dialog.*/
  301.     long                            lUser3;
  302.     long                            lUser4;
  303. };
  304. typedef struct TPrDlg TPrDlg, *TPPrDlg;
  305.  
  306. typedef pascal TPPrDlg (*PDlgInitProcPtr)(THPrint hPrint);
  307.  
  308. #if GENERATINGCFM
  309. typedef UniversalProcPtr PDlgInitUPP;
  310. #else
  311. typedef PDlgInitProcPtr PDlgInitUPP;
  312. #endif
  313.  
  314. enum {
  315.     uppPDlgInitProcInfo = kPascalStackBased
  316.          | RESULT_SIZE(SIZE_CODE(sizeof(TPPrDlg)))
  317.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(THPrint)))
  318. };
  319.  
  320. #if GENERATINGCFM
  321. #define NewPDlgInitProc(userRoutine)        \
  322.         (PDlgInitUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppPDlgInitProcInfo, GetCurrentArchitecture())
  323. #else
  324. #define NewPDlgInitProc(userRoutine)        \
  325.         ((PDlgInitUPP) (userRoutine))
  326. #endif
  327.  
  328. #if GENERATINGCFM
  329. #define CallPDlgInitProc(userRoutine, hPrint)        \
  330.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppPDlgInitProcInfo, (hPrint))
  331. #else
  332. #define CallPDlgInitProc(userRoutine, hPrint)        \
  333.         (*(userRoutine))((hPrint))
  334. #endif
  335.  
  336. /* This is the Printing Dialog Record. Only used by folks appending their own dialogs.
  337. Print Dialog: The Dialog Stream object. */
  338. struct TGnlData {
  339.     short                            iOpCode;
  340.     short                            iError;
  341.     long                            lReserved;                    /*more fields here depending on call*/
  342. };
  343. typedef struct TGnlData TGnlData;
  344.  
  345. struct TRslRg {
  346.     short                            iMin;
  347.     short                            iMax;
  348. };
  349. typedef struct TRslRg TRslRg;
  350.  
  351. struct TRslRec {
  352.     short                            iXRsl;
  353.     short                            iYRsl;
  354. };
  355. typedef struct TRslRec TRslRec;
  356.  
  357. struct TGetRslBlk {
  358.     short                            iOpCode;
  359.     short                            iError;
  360.     long                            lReserved;
  361.     short                            iRgType;
  362.     TRslRg                            xRslRg;
  363.     TRslRg                            yRslRg;
  364.     short                            iRslRecCnt;
  365.     TRslRec                            rgRslRec[27];
  366. };
  367. typedef struct TGetRslBlk TGetRslBlk;
  368.  
  369. struct TSetRslBlk {
  370.     short                            iOpCode;
  371.     short                            iError;
  372.     long                            lReserved;
  373.     THPrint                            hPrint;
  374.     short                            iXRsl;
  375.     short                            iYRsl;
  376. };
  377. typedef struct TSetRslBlk TSetRslBlk;
  378.  
  379. struct TDftBitsBlk {
  380.     short                            iOpCode;
  381.     short                            iError;
  382.     long                            lReserved;
  383.     THPrint                            hPrint;
  384. };
  385. typedef struct TDftBitsBlk TDftBitsBlk;
  386.  
  387. struct TGetRotnBlk {
  388.     short                            iOpCode;
  389.     short                            iError;
  390.     long                            lReserved;
  391.     THPrint                            hPrint;
  392.     Boolean                            fLandscape;
  393.     SInt8                            bXtra;
  394. };
  395. typedef struct TGetRotnBlk TGetRotnBlk;
  396.  
  397. extern pascal void PrPurge(void)
  398.  FOURWORDINLINE(0x2F3C, 0xA800, 0x0000, 0xA8FD);
  399. extern pascal void PrNoPurge(void)
  400.  FOURWORDINLINE(0x2F3C, 0xB000, 0x0000, 0xA8FD);
  401. extern pascal void PrOpen(void)
  402.  FOURWORDINLINE(0x2F3C, 0xC800, 0x0000, 0xA8FD);
  403. extern pascal void PrClose(void)
  404.  FOURWORDINLINE(0x2F3C, 0xD000, 0x0000, 0xA8FD);
  405. extern pascal void PrintDefault(THPrint hPrint)
  406.  FOURWORDINLINE(0x2F3C, 0x2004, 0x0480, 0xA8FD);
  407. extern pascal Boolean PrValidate(THPrint hPrint)
  408.  FOURWORDINLINE(0x2F3C, 0x5204, 0x0498, 0xA8FD);
  409. extern pascal Boolean PrStlDialog(THPrint hPrint)
  410.  FOURWORDINLINE(0x2F3C, 0x2A04, 0x0484, 0xA8FD);
  411. extern pascal Boolean PrJobDialog(THPrint hPrint)
  412.  FOURWORDINLINE(0x2F3C, 0x3204, 0x0488, 0xA8FD);
  413. extern pascal TPPrDlg PrStlInit(THPrint hPrint)
  414.  FOURWORDINLINE(0x2F3C, 0x3C04, 0x040C, 0xA8FD);
  415. extern pascal TPPrDlg PrJobInit(THPrint hPrint)
  416.  FOURWORDINLINE(0x2F3C, 0x4404, 0x0410, 0xA8FD);
  417. extern pascal void PrJobMerge(THPrint hPrintSrc, THPrint hPrintDst)
  418.  FOURWORDINLINE(0x2F3C, 0x5804, 0x089C, 0xA8FD);
  419. extern pascal Boolean PrDlgMain(THPrint hPrint, PDlgInitUPP pDlgInit)
  420.  FOURWORDINLINE(0x2F3C, 0x4A04, 0x0894, 0xA8FD);
  421. extern pascal TPPrPort PrOpenDoc(THPrint hPrint, TPPrPort pPrPort, Ptr pIOBuf)
  422.  FOURWORDINLINE(0x2F3C, 0x0400, 0x0C00, 0xA8FD);
  423. extern pascal void PrCloseDoc(TPPrPort pPrPort)
  424.  FOURWORDINLINE(0x2F3C, 0x0800, 0x0484, 0xA8FD);
  425. extern pascal void PrOpenPage(TPPrPort pPrPort, TPRect pPageFrame)
  426.  FOURWORDINLINE(0x2F3C, 0x1000, 0x0808, 0xA8FD);
  427. extern pascal void PrClosePage(TPPrPort pPrPort)
  428.  FOURWORDINLINE(0x2F3C, 0x1800, 0x040C, 0xA8FD);
  429. extern pascal void PrPicFile(THPrint hPrint, TPPrPort pPrPort, Ptr pIOBuf, Ptr pDevBuf, TPrStatus *prStatus)
  430.  FOURWORDINLINE(0x2F3C, 0x6005, 0x1480, 0xA8FD);
  431. extern pascal short PrError(void)
  432.  FOURWORDINLINE(0x2F3C, 0xBA00, 0x0000, 0xA8FD);
  433. extern pascal void PrSetError(short iErr)
  434.  FOURWORDINLINE(0x2F3C, 0xC000, 0x0200, 0xA8FD);
  435. extern pascal void PrGeneral(Ptr pData)
  436.  FOURWORDINLINE(0x2F3C, 0x7007, 0x0480, 0xA8FD);
  437. extern pascal void PrDrvrOpen(void)
  438.  FOURWORDINLINE(0x2F3C, 0x8000, 0x0000, 0xA8FD);
  439. extern pascal void PrDrvrClose(void)
  440.  FOURWORDINLINE(0x2F3C, 0x8800, 0x0000, 0xA8FD);
  441. extern pascal void PrCtlCall(short iWhichCtl, long lParam1, long lParam2, long lParam3)
  442.  FOURWORDINLINE(0x2F3C, 0xA000, 0x0E00, 0xA8FD);
  443. extern pascal Handle PrDrvrDCE(void)
  444.  FOURWORDINLINE(0x2F3C, 0x9400, 0x0000, 0xA8FD);
  445. extern pascal short PrDrvrVers(void)
  446.  FOURWORDINLINE(0x2F3C, 0x9A00, 0x0000, 0xA8FD);
  447.  
  448. #ifdef __CFM68K__
  449. #pragma lib_export off
  450. #endif
  451.  
  452. #if GENERATINGPOWERPC
  453. #pragma options align=reset
  454. #endif
  455.  
  456. #ifdef __cplusplus
  457. }
  458. #endif
  459.  
  460. #endif /* __PRINTING__ */
  461.